package com.itye.deom1;

import java.util.Random;

public class Group {
    private int groupId;
    private Student[] students;

    public Group(int groupId) {
        this.groupId = groupId;
        students = new Student[0];
    }

    public void addStudent(Student student) {
        Student[] newArray = new Student[students.length + 1];
        System.arraycopy(students, 0, newArray, 0, students.length);
        newArray[students.length] = student;
        students = newArray;
    }

    public int getGroupId() {
        return groupId;
    }

    public Student getRandomStudent() {
        if (students.length == 0) {
            return null;
        }
        Random random = new Random();
        int randomIndex = random.nextInt(students.length);
        return students[randomIndex];
    }
}